package cn.itsource.user.controller;

import cn.itsource.user.domain.vo.UserVo;
import cn.itsource.user.service.ICodeService;
import cn.itsource.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/code")
public class CodeController {

    @Autowired
    private ICodeService codeService;

    @PostMapping("/sendCode")
    public AjaxResult sendCode(@RequestBody UserVo userVo){
        try {
            //发送验证码
            codeService.sendCode(userVo);
            return AjaxResult.me();
        } catch (Exception e) {
            return AjaxResult.me().setSuccess(false).setMessage(e.getMessage());
        }

    }
}
